package sub.db.framework;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;

import com.lamian.db.vo.Address;

public class DBUtility {
	private static Session session;

	public static Session getSession() {
		return session;
	}

	public static void init() {
		Configuration cfg = new Configuration()
		// .addClass(AuctionItem.class)
				// .addClass(Bid.class)
				// .addClass(User.class)
				.addClass(Address.class).setProperty(Environment.HBM2DDL_AUTO,
						"update");
		 cfg.setProperty("hibernate.show_sql", "true");

		SessionFactory factory = cfg.buildSessionFactory();

		session = factory.openSession();

	}
	public static void DeleteRecord(String tableName,String ids){
		Transaction tx=session.beginTransaction();
		Query query=session.createQuery("Delete "+tableName+" tab where tab.id in("+ids+")");
		query.executeUpdate();
		tx.commit();
	}
}
